<?php

declare(strict_types=1);

namespace App\CustHub\Model;

use Mine\MineModel;

/**
 * @property int $room_id 群微信ID
 * @property int $robot_id 机器人ID
 * @property int $is_saved 是否已保存通讯录：0=否 1=是
 * @property int $is_do_not_disturb 是否启用免打扰：0=否 1=是
 * @property-read null|ChRoom $room 
 */
class ChRoomRobot extends MineModel
{
    public bool $incrementing = false;
    protected string $primaryKey = 'room_id';
    public bool $timestamps = false;
    /**
     * The table associated with the model.
     */
    protected ?string $table = 'ch_room_robot';

    /**
     * The attributes that are mass assignable.
     */
    protected array $fillable = ['room_id', 'robot_id', 'is_saved', 'is_do_not_disturb'];

    /**
     * The attributes that should be cast to native types.
     */
    protected array $casts = ['room_id' => 'integer', 'robot_id' => 'integer', 'is_saved' => 'integer', 'is_do_not_disturb' => 'integer'];

    /**
     * 群
     * @return \Hyperf\Database\Model\Relations\BelongsTo
     */
    public function room(): \Hyperf\Database\Model\Relations\BelongsTo
    {
        return $this->belongsTo(ChRoom::class,'room_id','id');
    }

    public function robot()
    {
        return $this->hasOne(ChRobot::class,'id','robot_id');
    }
}
